<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../film-assets/js/common.js"></script>
    <link rel="stylesheet" href="../film-assets/css/base.css">
    <link rel="stylesheet" href="../../assets/font/iconfont.css">
    <link rel="stylesheet" href="./util/vue-message.css">
</head>
<body>
    <div id="app" class="app">
        <nav-bar></nav-bar>
        <div class="content-box">
            <div class="films-box">
                <div class="list-name">
                    <span>热门电影</span>
                </div>
                <!-- 
                    1.静态页面的构成
                    2.组件化的分解
                    3.数据的请求对接  ==> 数据为对接前的组件复用运行正常，数据对接后一个页面正常其他页面异常
                    4.功能的优化和bug修复
                -->
                <film-list class="content-list" :list="films"></film-list>
            </div>
        </div>
    </div>
    <script src="../../assets/axios/axios.js"></script>
    <script type="module"> 
        import { createApp } from "../../assets/vue3/vue.esm-browser.js";
        import api from "./api/api.js"
        import message from "./util/vue-message.js"
        import NavBar from "./filmComponent/NavBar.js";
        import FilmList from "./filmComponent/FilmList.js";
        createApp({
            components: {
                NavBar,FilmList
            },
            data(){
                return {
                    films:[]
                }
            },
            methods: {
                async initFilms() {
                    let { state,data } = await this.$api.loadFilms({ pageNum:1,pageSize:12 });
                    if(!state){
                        this.$showTip("数据加载失败","","error");
                        return;
                    }
                    this.films = data;
                }
            },
            created () {
                this.initFilms();
            },
        })
        .use(api)
        .use(message)
        .mount("#app")
    </script>
</body>
</html>